package com.openingedu.mba.util;

import java.util.Map;

import com.openingedu.mba.entity.QuestionVO;

import android.os.Handler;
import android.os.Message;

public abstract class PracticeHandler extends Handler {

	private static final String TAG = PracticeHandler.class.getSimpleName();

	/**
	 * 回答正确
	 */
	public static final int ANSWER_CORRECT = 1;

	/**
	 * 回答错误
	 */
	public static final int ANSWER_FAULT = 0;

	/**
	 * 练习结束
	 */
	public static final int PRACTICE_OVER = 2;

	/* (non-Javadoc)
	 * @see android.os.Handler#handleMessage(android.os.Message)
	 */
	public void handleMessage(Message message) {
		QuestionVO question;
		switch (message.what) {
			case ANSWER_CORRECT:
				question = (QuestionVO) message.obj;
				correctQuestion(question);
				break;
			case ANSWER_FAULT:
				Map<String, Object> messageMap = (Map<String, Object>) message.obj;
				question = (QuestionVO) messageMap.get("question");
				Integer faultOptionID = (Integer) messageMap.get("faultOptionID");
				faultOption(question, faultOptionID);
				break;
			case PRACTICE_OVER:
				question = (QuestionVO) message.obj;
				overPractice();
				break;
		}
	}

	public abstract void overPractice();

	public abstract void faultOption(QuestionVO question, Integer faultOptionID);

	public abstract void correctQuestion(QuestionVO question);
}
